package com.guide.framework.datasource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


public class DynamicDataSourceHolder {
	protected static final Logger logger = LoggerFactory.getLogger(DynamicDataSourceHolder.class);

	private static final ThreadLocal<String> threadDataSource = new ThreadLocal<String>();

	public static String getThreadDataSource() {
		String dataSourceName = threadDataSource.get();
		if (dataSourceName != null) {
			logger.debug("DataSource Name:[" + dataSourceName + "]");
		}
		return dataSourceName;
	}

	public static void setThreadDataSource(String dataSourceName) {
		threadDataSource.set(dataSourceName);
	}

	public static void clearThreadDataSource() {
		threadDataSource.remove();
	}

}
